<!--模板 html-->
<template>
  <div>
    <!--按钮 html-->
    <div class="tab_btns">
        <el-button type="primary" size="small" @click="toFormHandler">新增</el-button>
    </div>

    <!--表格 html-->
    <div class="tab_content">
      <el-table :data="BaseLog" style="width: 100%">

      <el-table-column
        prop="id"
        label="ID"
        width="180">
      </el-table-column>

      <el-table-column
        prop="realname"
        label="真实姓名"
        width="180">
      </el-table-column>

      <el-table-column
        prop="method"
        label="方法">
      </el-table-column>

      <el-table-column
        prop="content"
        label="内容">
      </el-table-column>

      <el-table-column
        prop="logTime"
        label="时间">
        <template slot-scope="scope">
	        {{scope.row.logTime | fmtDate}}
	      </template> 
      </el-table-column>

      <!-- 操作列 -->
        <el-table-column width="100" align="center" label="操作">
          <template slot-scope="scope">
            <el-button type="text" @click="editHandler(scope.row)">修改</el-button>
            <el-button type="text" @click="deleteHandler(scope.row)">删除</el-button>
          </template>
        </el-table-column>
    </el-table>
    </div>
  </div>
</template>

<!--脚本 js-->
<script>
import  {del, get} from '@/utils/request'
export default {
  //定义变量，在模板中直接用
    data(){
        return {
            BaseLog:[],
            visible:false
        }
    },
    //定义事件处理函数、方法
    methods:{
        // 删除的处理函数
        deleteHandler(row){
          this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        type: 'warning'
        }).then(() => {
          let url = "http://localhost:8888/baseLog/deleteById"
            del(url,{id:row.id}).then(resp =>{
              // 1. 提示
              this.$message({type:"success",message:resp.message});
              // 2. 刷新
              this.loadBaseLog();
            })
          })
      },
        editHandler(row){
          this.$router.push({ 
            path:"/litongjun/baselogform" ,
            query:row
          })
        },
        // 跳转到温室大棚录入页面
        toFormHandler(){
          // 跳转
          this.$router.push({ path:"/litongjun/baselogform" })
        },
        //查询所有数据
        loadBaseLog(){
            let url = "http://localhost:8888/baseLog/query"
            get(url).then(resp => {
                //获取数据后做的事情
                this.BaseLog = resp.data;
            })
        }
    },
    //生命周期钩子函数
    created(){
        this.loadBaseLog();
    }

}
</script>


<!--css 样式-->
<style lang="sass" scoped>

</style>
